<template>
	<u-popup round="20" :show="show">
		<view class="popup-box">
			<view class="box">
				<view class="tilte">添加人员</view>
				<image class="img" src="/static/home/close.png" mode="scaleToFill" @click="close" />
			</view>
			<view class="item" v-for="(item, index) in workerList" :key="index" @click="confirmProject(item)">
				<view class="name-box">
					<image v-if="value == item" class="img" src="/static/home/select.png" mode="scaleToFill" />
					<image v-else class="img" src="/static/home/noSelect.png" mode="scaleToFill" />
					<text class="text name">{{item.workerName}}</text>
				</view>
				<text class="text">{{item.workerPhone}}</text>
				<text class="text">{{item.workType}}</text>
				<!-- <text>普工</text> -->
			</view>
		</view>
	</u-popup>

</template>

<script>
	export default {
		data() {
			return {
				workerList: [],
			}
		},
		props: {
			show: {
				type: Boolean,
				default: false
			},
			value: {
				type: Object,
				default: () => {}
			}
		},
		mounted() {
			this.getWorker();
		},
		methods: {
			// 获取点工列表
			getWorker() {
				this.$api.workerList({}).then(res => {
					if (res.code == 200) {
						this.workerList = res.data;
						console.log(this.workerList)
					}
				})
			},
			confirmProject(item) {
				this.$emit('update:value', item)
				this.close()
			},
			close() {
				this.$emit('update:show', false)
			}
		}
	}
</script>

<style scoped lang="scss">
	.popup-box {
		padding: 20rpx 20rpx 30rpx 30rpx;
		height: 500rpx;
		overflow: hidden;

		.box {
			display: flex;
			justify-content: space-between;
			align-items: center;
			margin-bottom: 30rpx;


			.tilte {
				font-weight: bold;
				font-size: 32rpx;
				color: #1A1A1A;
			}

			.img {
				width: 24rpx;
				height: 24rpx;
			}
		}


		.item {
			padding: 20rpx 150rpx 20rpx 0;
			display: flex;
			align-items: center;
			justify-content: space-between;

			border-bottom: 1rpx solid #E5E5E5;

			&:last-child {
				border-bottom: none;
			}


			.name-box {
				display: flex;
				align-items: center;

				.img {
					width: 32rpx;
					height: 32rpx;
					margin-right: 20rpx;
				}

				.name {
					@include ellipsis(1);
					width: 100rpx;
				}
			}


			.text {
				font-weight: 500;
				font-size: 32rpx;
				color: #1A1A1A;
			}


		}
	}
</style>